﻿using BaoVeBienCuong.Playgame.enemy;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;


namespace BaoVeBienCuong.Playgame.army
{
    public class LinhCanChien
    {
        #region
        protected int count; /* biến đếm để vẽ ảnh động */
        protected string Loai; /* các loại lính: sword,knight,shogun*/
        protected int level; /* mức cơ bản, trưởng thành, nâng cấp */
        protected int sosao; /* mức nâng cấp sao của tướng */
        protected string huong; /* hướng đứng của tướng */
        protected Vector2 position; /* vị trí của tướng */
        protected Vector2 Lechposition; /* độ lệch so với vị trí để vẽ tướng chuẩn hơn */
        protected Vector2 size; /* kích thước của tướng */
        protected Vector2 sizeImages;  /* kích thước bảng ảnh */
        protected Texture2D image; /* ảnh hiển thị */
        protected Texture2D imagesao; /* ảnh sao */
        protected Vector2 index; /* vị trí tướng trong map */
        protected Texture2D imageLock;
        protected Texture2D imageTam;
        protected float scale;/* tỉ lệ vẽ ảnh */
        protected bool isVisible;/* lính tồn tại */
        protected bool isNangcap;
        protected NangCap[] nangcaps = new NangCap[4];
        protected bool isLock;
        Random rd = new Random();
        #endregion
        /* Khởi tạo lính */
        public LinhCanChien()
        {
            sosao = 1;
            isLock = true;
            count = 0;
            sosao = 1;
            huong = "Bottom";
            Lechposition = new Vector2(0, 0);
            position = new Vector2(0, 0);
            size = new Vector2(40, 40);
            index = new Vector2(0, 0);
            scale = 0.5f;
            isNangcap = false;

        }
        public LinhCanChien(string loai, int level)
        {
            setLoai(loai, level);
        }

        /* đặt các thuộc tính cho lính */
        public virtual void setLoai(string loai, int level)
        {
            sosao = 1;
            this.level = level;
            isLock = true;
            count = 0;
            sosao = 1;
            this.Loai = loai;
            huong = "Bottom";
            Lechposition = new Vector2(0, 0);
            position = new Vector2(0, 0);
            size = new Vector2(40, 40);
            index = new Vector2(0, 0);
            scale = 0.5f;
            for (int i = 0; i < 4; i++)
            {
                nangcaps[i] = new NangCap(loai, i, index);
            }
            isNangcap = false;
        }
        /* get, set các chỉ số */
        public string getLoai()
        {
            return Loai;
        }
        public void setHuong(string huong)
        {
            this.huong = huong;
        }
        public void setIndex(Vector2 chiso)
        {
            index = chiso;
            size = new Vector2(GamePage.sizeImageBackGround.X / GamePage.sizeMap.Y, GamePage.sizeImageBackGround.Y / GamePage.sizeMap.X);
            position = new Vector2(chiso.Y * size.X, chiso.X * size.Y);
            foreach (NangCap nangcap in nangcaps)
            {
                nangcap.setIndex(index);
            }
            isVisible = true;
        }
        public Vector2 getTam()
        {
            return position;
        }
        public void setPosition(Vector2 posi)
        {
            isVisible = true;
            position = posi;
        }
        public void setLock(bool t)
        {
            isLock = t;
        }
        public bool getLock()
        {
            return isLock;
        }

        /* load ảnh cho lính */
        public virtual void Load(ContentManager cont)
        {
            imageTam = cont.Load<Texture2D>("images/towers/HongTam");
            imageLock = cont.Load<Texture2D>("images/store/lock");
            if (!Loai.Equals("shogun")) imagesao = cont.Load<Texture2D>("images/towers/star");
            foreach (NangCap nangcap in nangcaps)
            {
                nangcap.Load(cont);
            }
            if (Loai.Equals("sword"))
            {
                LoadSword(cont);
            }
            else if (Loai.Equals("knight"))
            {
                LoadKnight(cont);
            }
            else
            {
                LoadShogun(cont);
            }
        }
        public void LoadSword(ContentManager cont)
        {
            if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
            {
                image = cont.Load<Texture2D>("images/towers/sword_" + level + "1");

            }
            else if (huong.Equals("Bottom"))
            {
                image = cont.Load<Texture2D>("images/towers/sword_" + level + "0");
            }
            else
            {
                image = cont.Load<Texture2D>("images/towers/sword_" + level + "2");
            }

            if (level == 0)
            {
                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(965, 193);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-30, -105) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-30, -105) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(608, 153);
                    Lechposition = new Vector2(-40, -70) * scale;
                }
                else
                {
                    sizeImages = new Vector2(1065, 228);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-85, -110) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-0, -110) * scale;
                    }
                }
                #endregion
            }
            else if (level == 1)
            {
                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(1545, 264);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-90, -140) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-90, -140) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(756, 174);
                    Lechposition = new Vector2(-50, -70) * scale;
                }
                else
                {
                    sizeImages = new Vector2(1365, 308);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-100, -120) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-45, -130) * scale;
                    }

                }
                #endregion
            }
            else
            {
                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(1565, 293);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-85, -155) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-100, -155) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(844, 202);
                    Lechposition = new Vector2(-80, -70) * scale;
                }
                else
                {
                    sizeImages = new Vector2(1525, 297);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-95, -110) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-75, -120) * scale;
                    }

                }
                #endregion
            }
        }
        public void LoadKnight(ContentManager cont)
        {
            if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
            {
                image = cont.Load<Texture2D>("images/towers/knight_" + level + "1");
            }
            else if (huong.Equals("Bottom"))
            {
                image = cont.Load<Texture2D>("images/towers/knight_" + level + "0");
            }
            else
            {
                image = cont.Load<Texture2D>("images/towers/knight_" + level + "2");
            }

            if (level == 0)
            {
                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(1060, 200);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-60, -120) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-20, -125) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(612, 159);
                    Lechposition = new Vector2(-30, -70) * scale;
                }
                else
                {
                    sizeImages = new Vector2(930, 216);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-50, -100) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-5, -105) * scale;
                    }
                }
                #endregion

                //if (huong.Equals("TopLeft") || huong.Equals("TopRight")) sizeImages = new Vector2(1060, 200);
                //else if (huong.Equals("Bottom")) sizeImages = new Vector2(612, 159);
                //else sizeImages = new Vector2(930, 216);
            }
            else if (level == 1)
            {

                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(1460, 267);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-80, -110) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-90, -115) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(684, 230);
                    Lechposition = new Vector2(5, -70) * scale;
                }
                else
                {
                    sizeImages = new Vector2(1745, 248);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-100, -70) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-110, -70) * scale;
                    }

                }
                #endregion
                //if (huong.Equals("TopLeft") || huong.Equals("TopRight")) sizeImages = new Vector2(1460, 267);
                //else if (huong.Equals("Bottom")) sizeImages = new Vector2(684, 230);
                //else sizeImages = new Vector2(1745, 248);
            }
            else
            {
                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(1325, 308);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-85, -140) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-60, -140) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(920, 205);
                    Lechposition = new Vector2(0, -70) * scale;
                }
                else
                {
                    sizeImages = new Vector2(1510, 270);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-115, -90) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-60, -80) * scale;
                    }

                }
                #endregion
                //if (huong.Equals("TopLeft") || huong.Equals("TopRight")) sizeImages = new Vector2(1325, 308);
                //else if (huong.Equals("Bottom")) sizeImages = new Vector2(920, 205);
                //else sizeImages = new Vector2(1510, 270);
            }
        }
        public void LoadShogun(ContentManager cont)
        {
            if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
            {
                image = cont.Load<Texture2D>("images/towers/shogun_" + level + "1");
            }
            else if (huong.Equals("Bottom"))
            {
                image = cont.Load<Texture2D>("images/towers/shogun_" + level + "0");
            }
            else
            {
                image = cont.Load<Texture2D>("images/towers/shogun_" + level + "2");
            }

            if (level == 0)
            {
                #region
                if (huong.Equals("TopLeft") || huong.Equals("TopRight"))
                {
                    sizeImages = new Vector2(2035, 440);
                    if (huong.Equals("TopRight"))
                    {
                        Lechposition = new Vector2(-150, -260) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-130, -260) * scale;
                    }
                }
                else if (huong.Equals("Bottom"))
                {
                    sizeImages = new Vector2(1124, 248);
                    Lechposition = new Vector2(-120, -110) * scale;
                }
                else
                {
                    sizeImages = new Vector2(1985, 374);
                    if (huong.Equals("Left"))
                    {
                        Lechposition = new Vector2(-140, -200) * scale;
                    }
                    else
                    {
                        Lechposition = new Vector2(-130, -200) * scale;
                    }
                }
                #endregion
            }
        }
        /* vẻ ảnh lính */
        public virtual void Draw(SpriteBatch sprite, SpriteFont font, bool visibleStar = true)
        {
            scale = GamePage.scale;
            if (isVisible)
            {
                if (isNangcap && visibleStar) // vẽ phạm vi bắn
                {
                    sprite.Draw(imageTam, (position + ((512 - GamePage.save.GetValue(Loai, level, sosao).getTamXa()) * new Vector2(0.15f, 0.15f)) - new Vector2((float)Math.Sqrt(2) - 0.5f, (float)Math.Sqrt(2) - 0.5f) * GamePage.save.GetValue(Loai, level, sosao).getTamXa()) * scale + GamePage.DoLech, new Rectangle(0, 0, 531, 531),
                                                 Color.White, 0, Vector2.Zero, (GamePage.save.GetValue(Loai, level, sosao).getTamXa() * 2 / 531) * scale, SpriteEffects.None, 0);
                }
                if (huong.Equals("Bottom"))
                {
                    if (visibleStar || (isNangcap && !visibleStar)) //isNang cap la o trong cua hang
                    {
                        sprite.Draw(image, position * scale + Lechposition + GamePage.DoLech, new Rectangle((int)sizeImages.X / 4 * (count / 6), 0, (int)sizeImages.X / 4, (int)sizeImages.Y),
                            Color.White * (visibleStar == true ? 1.0f : (isLock == true ? 0.5f : 1.0f)), 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                    }
                    else
                    {
                        sprite.Draw(image, position * scale + Lechposition + GamePage.DoLech, new Rectangle(0, 0, (int)sizeImages.X / 4, (int)sizeImages.Y),
                            Color.White * (visibleStar == true ? 1.0f : (isLock == true ? 0.5f : 1.0f)), 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                    }
                    if (!visibleStar && isLock) // vẽ khóa
                    {
                        if (imageLock != null)
                            sprite.Draw(imageLock, position * scale + new Vector2(50, 50) + GamePage.DoLech, new Rectangle(0, 0, 64, 64),
                                Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                    }
                    size = new Vector2(sizeImages.X / 4, sizeImages.Y) * scale;
                    if (!GamePage.isPause) count++;
                    if (count >= 24) count = 0;
                }
                else
                {
                    if (huong.Equals("Left") || huong.Equals("TopLeft"))
                    {
                        sprite.Draw(image, position * scale + Lechposition + GamePage.DoLech, new Rectangle((int)sizeImages.X / 5 * (count / 2 > 4 ? 0 : count / 2), 0, (int)sizeImages.X / 5, (int)sizeImages.Y),
                                                Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                    }
                    else
                    {
                        sprite.Draw(image, position * scale + Lechposition + GamePage.DoLech, new Rectangle((int)sizeImages.X / 5 * (count / 2 > 4 ? 0 : count / 2), 0, (int)sizeImages.X / 5, (int)sizeImages.Y),
                                                Color.White, 0, Vector2.Zero, scale, SpriteEffects.FlipHorizontally, 0);
                    }
                    if (!GamePage.isPause)
                    {
                        if (GamePage.speed == 50 || (GamePage.speed == 30 && GamePage.counttocdo % 2 != 0) || (GamePage.speed == 40 && GamePage.counttocdo % 5 != 0))
                            count++;
                    }
                    if (count >= (int)(40 / GamePage.save.GetValue(Loai, level, sosao).getTocdo())) count = 0;
                }
                if (visibleStar) //  vẽ sao
                {
                    if (!Loai.Equals("shogun"))
                    {
                        for (int k = 1; k <= sosao; k++)
                        {
                            sprite.Draw(imagesao, position * scale + GamePage.DoLech + new Vector2(60 + 18 * k, -45) * scale, new Rectangle(0, 0, 16, 16),
                                                         Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
                        }
                    }
                    if (isNangcap)
                    {
                        foreach (NangCap nangcap in nangcaps)
                        {
                            nangcap.Draw(sprite, font, sosao, level);
                        }
                    }
                }
            }
        }

        public virtual void DrawInformation(SpriteBatch sprite, SpriteFont font, int loai, int lever)
        {
            Info info = getInfo(loai, lever);
            sprite.DrawString(font, info.getName(), new Vector2(550, 100), Color.Yellow, 0, Vector2.Zero, 1.5f, SpriteEffects.None, 0);
            sprite.DrawString(font, "Sát thương : " + info.getSatthuong().ToString(), new Vector2(500, 150), Color.White, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
            sprite.DrawString(font, "Tốc độ : " + info.getTocdo().ToString(), new Vector2(500, 200), Color.White, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
            sprite.DrawString(font, "Tầm xa : " + info.getTamXa().ToString(), new Vector2(500, 250), Color.White, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
            sprite.DrawString(font, "Giá : " + info.getGia().ToString(), new Vector2(500, 300), Color.White, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
        }
        /* hành động của lính */
        public virtual void Ban(List<Enemy> enemy)
        {
            bool dangban = false;
            if (isVisible)
            {
                for (int j = 0; j < enemy.Count; j++)
                {
                    if (GamePage.save.GetValue(Loai, level, sosao).getTamXa() * scale >= (float)KhoangCach(enemy[j]) && enemy[j].getEnable() && enemy[j].getLoai() != 1)
                    {
                        Quay(enemy[j]);
                        dangban = true;
                        if (count % ((int)(40 / GamePage.save.GetValue(Loai, level, sosao).getTocdo())) == 4)
                        {
                            enemy[j].setTruMau(GamePage.save.GetValue(Loai, level, sosao).getSatthuong(),
                                (rd.Next(1000) % 100 <= GamePage.save.GetValue(Loai, level, sosao).getTiLe()) ? GamePage.save.GetValue(Loai, level, sosao).getHieuUng() : "");
                            MainPage.PlayHieuUng("one_handed", false);
                        }
                        break;
                    }
                }
            }
            if (dangban == false)
            {
                huong = "Bottom";
            }
        }
        protected double KhoangCach(Enemy enemy)
        {
            /*
            if (enemy.getIndex().X < index.X)
            {
                if (enemy.getIndex().Y > index.Y)
                {
                    return Vector2.Distance((position + new Vector2(size.X, 0)), (enemy.getPosition() + new Vector2(0, size.Y))) * scale;
                }
                else
                {
                    return Vector2.Distance((position), (enemy.getPosition() + new Vector2(size.X, size.Y))) * scale;
                }
            }
            else
            {
                if (enemy.getIndex().Y > index.Y)
                {
                    return Vector2.Distance((position + new Vector2(size.X, 0)), (enemy.getPosition())) * scale;
                }
                else
                {
                    return Vector2.Distance((position), (enemy.getPosition() + new Vector2(size.X))) * scale;
                }
            }*/
            return Vector2.Distance((position), (enemy.getPosition())) * scale;
        }
        public void Quay(Enemy enemy)
        {
            if (enemy.getIndex().X < index.X)
            {
                if (enemy.getIndex().Y >= index.Y)
                {
                    huong = "TopRight";
                }
                else
                {
                    huong = "TopLeft";
                }
            }
            else
            {
                if (enemy.getIndex().Y >= index.Y)
                {
                    huong = "Right";
                }
                else
                {
                    huong = "Left";
                }
            }
        }
        public void setVisible(bool t)
        {
            isVisible = t;
        }
        public bool getVisible()
        {
            return isVisible;
        }
        public bool isTouched(Vector2 posi, bool visibleStar = true)
        {
            if (visibleStar)
            {
                if (index == GamePage.getIndexTouch(posi))
                {
                    MainPage.PlayHieuUng("Click", false);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                if (posi.X >= 550 || posi.Y >= 450) return false;
                posi = (posi * scale) - Lechposition;
                if (posi.X >= (position.X * scale + Lechposition.X + GamePage.DoLech.X) && posi.X <= ((position.X * scale + Lechposition.X + GamePage.DoLech.X) + size.X) && posi.Y >= (position.Y * scale + Lechposition.Y + GamePage.DoLech.Y) && posi.Y <= ((position.Y * scale + Lechposition.Y + GamePage.DoLech.Y) + size.Y))
                {
                    MainPage.PlayHieuUng("Click", false);
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        public void setNangCap(bool i)
        {
            isNangcap = i;
        }
        public bool getNangCap()
        {
            return isNangcap;
        }
        public virtual bool TouchNangCap(Vector2 posi)
        {
            if (Vector2.Distance(posi, position * scale + GamePage.DoLech) > 300 * GamePage.scale) // nếu chạm ngoài vùng phủ sóng thì dừng nâng cấp
            {
                return false;
            }
            else
            {
                foreach (NangCap nangcap in nangcaps)
                {
                    if (nangcap.isTouch(posi))
                    {
                        MainPage.PlayHieuUng("Click", false);
                        int k = nangcap.getType();
                        if (k == 3)
                        {
                            GamePage.money += nangcap.getPrice();
                            MainPage.PlayHieuUng("Gold", false);
                            isVisible = false;
                            return false;
                        }
                        else if (k == 2)
                        {
                            MainPage.PlayHieuUng("Upgrade", false);
                            sosao++;
                            if (sosao > 3) sosao = 3;
                            GamePage.money -= nangcap.getPrice();
                        }
                        else if (k == 1)
                        {
                            MainPage.PlayHieuUng("Upgrade", false);
                            GamePage.money -= nangcap.getPrice();
                            level = 1;
                            sosao = 1;
                        }
                        else if (k == 0)
                        {
                            MainPage.PlayHieuUng("Upgrade", false);
                            GamePage.money -= nangcap.getPrice();
                            level = 2;
                            sosao = 1;
                        }
                    }
                }
                return true;
            }
        }
        public Vector2 getIndex()
        {
            return index;
        }
        public Info getInfo(string loai, int level, int sao)
        {
            if (loai.Equals("sword"))
            {
                return getInfo(level, sao);
            }
            else if (loai.Equals("archer"))
            {
                return getInfo(3 + level, sao);
            }
            else if (loai.Equals("knight"))
            {
                return getInfo(6 + level, sao);
            }
            else if (loai.Equals("shaman"))
            {
                return getInfo(9 + level, sao);
            }
            return getInfo(12, sao);
        }
        public Info getInfo(int loai, int lever)
        {
            Info info = new Info();
            if (loai == 0)
            {
                #region kiếm sĩ
                info.setHieuUng("", 0);
                info.setName("Kiếm sĩ");
                if (lever == 1)
                {
                    info.set(10, 1.0f, 192, 0);
                }
                else if (lever == 2)
                {
                    info.set(12, 1.0f, 208, 0);
                }
                else
                {
                    info.set(15, 1.3f, 224, 0);
                }
                #endregion
            }
            else if (loai == 1)
            {
                #region vô ảnh kiếm
                info.setHieuUng("lam do", 20);
                info.setName("Vô ảnh kiếm");
                if (lever == 1)
                {
                    info.set(16, 1.2f, 240, 0);
                }
                else if (lever == 2)
                {
                    info.set(19, 1.4f, 256, 0);
                }
                else
                {
                    info.set(25, 1.6f, 272, 0);
                }
                #endregion
            }
            else if (loai == 2)
            {
                #region đao vương
                info.setHieuUng("dot tu", 10);
                info.setName("Đao vương");
                if (lever == 1)
                {
                    info.set(18, 1.3f, 272, 5000);
                }
                else if (lever == 2)
                {
                    info.set(22, 1.4f, 288, 5000);
                }
                else
                {
                    info.set(28, 1.5f, 304, 5000);
                }
                #endregion
            }
            else if (loai == 3)
            {
                #region xạ thủ
                info.setHieuUng("", 0);
                info.setName("Xạ thủ");
                if (lever == 1)
                {
                    info.set(5, 1.9f, 448, 0);
                }
                else if (lever == 2)
                {
                    info.set(7, 2.1f, 464, 0);
                }
                else
                {
                    info.set(10, 2.1f, 480, 0);
                }
                #endregion
            }
            else if (loai == 4)
            {
                #region xạ thần
                info.setHieuUng("xuyen giap", 20);
                info.setName("Xạ thần");
                if (lever == 1)
                {
                    info.set(11, 2.3f, 496, 0);
                }
                else if (lever == 2)
                {
                    info.set(13, 2.3f, 512, 0);
                }
                else
                {
                    info.set(15, 2.5f, 528, 0);
                }
                #endregion
            }
            else if (loai == 5)
            {
                #region bá vương tiễn
                info.setHieuUng("chi mang", 25);
                info.setName("Bá vương tiễn");
                if (lever == 1)
                {
                    info.set(13, 2.2f, 512, 20000);
                }
                else if (lever == 2)
                {
                    info.set(16, 2.4f, 528, 20000);
                }
                else
                {
                    info.set(20, 2.5f, 544, 20000);
                }
                #endregion
            }
            else if (loai == 6)
            {
                #region thủ sĩ
                info.setHieuUng("", 0);
                info.setName("Thủ sĩ");
                if (lever == 1)
                {
                    info.set(21, 0.7f, 240, 0);
                }
                else if (lever == 2)
                {
                    info.set(26, 0.8f, 256, 0);
                }
                else
                {
                    info.set(32, 0.8f, 272, 0);
                }
                #endregion
            }
            else if (loai == 7)
            {
                #region thần thương
                info.setHieuUng("xuyen giap", 20);
                info.setName("Thần thương");
                if (lever == 1)
                {
                    info.set(33, 0.8f, 304, 0);
                }
                else if (lever == 2)
                {
                    info.set(37, 1f, 320, 0);
                }
                else
                {
                    info.set(41, 1.2f, 336, 0);
                }
                #endregion
            }
            else if (loai == 8)
            {
                #region kim đại phủ
                info.setHieuUng("chi mang", 25);
                info.setName("Kim đại phủ");
                if (lever == 1)
                {
                    info.set(35, 1f, 336, 15000);
                }
                else if (lever == 2)
                {
                    info.set(40, 1.2f, 352, 15000);
                }
                else
                {
                    info.set(44, 1.5f, 368, 15000);
                }
                #endregion
            }
            else if (loai == 9)
            {
                #region phiến vũ
                info.setHieuUng("", 0);
                info.setName("Phiến vũ");
                if (lever == 1)
                {
                    info.set(20, 0.7f, 448, 0);
                }
                else if (lever == 2)
                {
                    info.set(25, 0.8f, 464, 0);
                }
                else
                {
                    info.set(30, 0.8f, 480, 0);
                }
                #endregion
            }
            else if (loai == 10)
            {
                #region thủy trượng sư
                info.setHieuUng("lam cham", 20);
                info.setName("Thủy trượng sư");
                if (lever == 1)
                {
                    info.set(34, 1, 512, 20000);
                }
                else if (lever == 2)
                {
                    info.set(39, 1.2f, 528, 20000);
                }
                else
                {
                    info.set(45, 1.5f, 544, 20000);
                }
                #endregion
            }
            else if (loai == 11)
            {
                #region hỏa trượng sư
                info.setHieuUng("chay mau", 25);
                info.setName("Hỏa trượng sư");
                if (lever == 1)
                {
                    info.set(35, 1, 512, 20000);
                }
                else if (lever == 2)
                {
                    info.set(40, 1.2f, 528, 20000);
                }
                else
                {
                    info.set(45, 1.5f, 544, 20000);
                }
                #endregion
            }
            else
            {
                info.setHieuUng("dot tu", 20);
                info.set(50, 1.5f, 384, 0);
            }
            return info;
        }
    }
    public class Info
    {
        string name;
        float satthuong;
        float tocdo;
        float tamxa;
        float gia;
        string hieuung;
        int tile;
        public Info()
        {
            name = "";
            satthuong = 0;
            tocdo = 0;
            tamxa = 0;
            gia = 0;
            hieuung = "";
            tile = 0;
        }
        public void setHieuUng(string hu, int tl)
        {
            hieuung = hu;
            tile = tl;
        }
        public void set(float st, float td, float tx, float g)
        {
            satthuong = st;
            tocdo = td;
            tamxa = tx;
            gia = g;

        }
        public string getName()
        {
            return name;
        }
        public void setName(string s)
        {
            name = s;
        }
        public float getSatthuong()
        {
            return satthuong;
        }
        public void setSatthuong(float st)
        {
            satthuong = st;
        }
        public float getTocdo()
        {
            return tocdo;
        }
        public void setTocdo(float st)
        {
            tocdo = st;
        }
        public float getTamXa()
        {
            return tamxa;
        }
        public void setTamxa(float st)
        {
            tamxa = st;
        }
        public float getGia()
        {
            return gia;
        }
        public void setGia(float st)
        {
            gia = st;
        }
        public string getHieuUng()
        {
            return hieuung;
        }
        public int getTiLe()
        {
            return tile;
        }
    }
}
